var t = getApp(), a = void 0;

Page({
    data: {
        list: [],
        total: 0,
        currentPage: 1,
        pageSize: 10,
        deadline: []
    },
    onLoad: function(t) {
        (a = this).getList(0), a.getDeadline();
    },
    getList: function(e) {
        wx.showLoading({
            title: "加载中"
        }), 0 == e ? this.data.currentPage = 1 : this.data.currentPage += 1, t.com.post("wx/coupon/nouse", {
            currentPage: this.data.currentPage,
            pageSize: this.data.pageSize
        }, function(t) {
            if (wx.hideLoading(), 0 === t.errno) {
                var i = [];
                if (0 == e) i = t.data.data; else {
                    i = a.data.list;
                    for (var n in t.data.data) i.push(t.data.data[n]);
                }
                a.setData({
                    list: i,
                    total: t.data.count
                });
            }
        });
    },
    getDeadline: function() {
        t.com.post("wx/coupon/deadline", {
            pageSize: 1
        }, function(t) {
            0 === t.errno && a.setData({
                deadline: t.data.data
            });
        });
    },
    onPullDownRefresh: function() {
        a.getList(0);
    },
    onReachBottom: function() {
        this.data.total > this.data.list.length && a.getList(1);
    }
});